import torch

a = torch.rand(2,3)
b = torch.rand(2,3)
print(a)
print(b)

print(torch.eq(a,b))
print(torch.equal(a,b))

print(torch.ge(a,b))
print(torch.gt(a,b))
print(torch.le(a,b))
print(torch.lt(a,b))
print(torch.ne(a,b))

##sort
a = torch.tensor([[1,4,4,3,5],
                 [5,4,3,6,7]])
print(a.shape)
print(torch.sort(a,dim = 1,descending=False))


##topK

a =torch.tensor([[1,4,4,3,5],
                 [5,4,3,6,7]])
print(a.shape)
print(torch.topk(a,k=2,dim = 1))
print(torch.kthvalue(a,k=2,dim = 0))
print(torch.kthvalue(a,k=2,dim = 1))

a = torch.rand(2,3)
print(a)
print(torch.isfinite(a))
print(torch.isfinite(a/0))
print(torch.isinf(a/0))
print(torch.isnan(a))

import numpy as np
a = torch.tensor([1,2,np.nan])
print(torch.isnan(a))